
        package com.zzyl.controller;

        import com.zzyl.base.ResponseResult;
        import com.zzyl.dto.BedDto;
        import com.zzyl.service.BedService;
        import com.zzyl.vo.BedVo;
        import io.swagger.annotations.Api;
        import io.swagger.annotations.ApiOperation;
        import io.swagger.annotations.ApiParam;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.*;

        import java.util.List;

@RestController
@RequestMapping("/bed")
@Api(tags = "床位管理相关接口")
public class BedController extends BaseController {

    @Autowired
    private BedService bedService;

    @GetMapping("/read/room/{roomId}")
    @ApiOperation(value = "根据房间id查询床位", notes = "根据房间id查询该房间的所有床位信息")
    public ResponseResult<List<BedVo>> readBedByRoomId(
            @ApiParam(value = "房间ID", required = true) @PathVariable("roomId") Long roomId) {
        List<BedVo> beds = bedService.getBedsByRoomId(roomId);
        return success(beds);
    }


    @PostMapping("/create")
    @ApiOperation(value = "创建床位", notes = "传入床位信息以创建新的床位")
    public ResponseResult ceatedBed( @ApiParam(value = "床位信息", required = true)@RequestBody BedDto bedDto){
        bedService.add(bedDto);
        return success();
    }


    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除床位", notes = "根据床位ID删除对应的床位信息")
    public ResponseResult deleteBed(@PathVariable("id") Long id){
        bedService.deletebyid(id);
        return success();
    }

    @GetMapping("/read/{id}")
    @ApiOperation(value = "查询床位", notes = "根据床位ID查询对应的床位信息")
    public ResponseResult readBed(@PathVariable("id") Long id){
        BedVo bedVo=  bedService.Getbyid(id);
        return success(bedVo);
    }


    @PutMapping("/update")
    @ApiOperation(value = "更新床位", notes = "传入床位信息以更新对应的床位信息")
    public ResponseResult updateBed(@RequestBody BedDto bedDto){
        bedService.update(bedDto);
        return success();
    }

}